import request from '../utils/request';
import { getToken } from '../utils/user';
import axios from 'axios';
import { baseApi } from "../utils/request"
import { pushScopeId } from 'vue';


export const uploadFile = (file, data) => {
    console.log("file", file);
    let param = new FormData();
    param.append('file', file.file);
    param.append("folder", data.folder ? data.folder : "");
    param.append("apiToken", getToken());
    let config = {
        header: { 'Content-Type': 'multipart/form-data' }
    }
    return axios.post(baseApi + '/account/uploadFile', param, config)
}

// 用户管理
export const login = query => {
    return request({
        url: '/admin/login',
        method: 'post',
        data: query
    });
};


// account
export const accountList = query => {
    return request({
        url: '/admin/account/index',
        method: 'get',
        params: query
    });
};
export const accountCreate = query => {
    return request({
        url: '/admin/account/create',
        method: 'post',
        data: query
    });
};
export const accountUpdate = query => {
    return request({
        url: '/admin/account/update',
        method: 'post',
        data: query
    });
};


// tag
export const tagList = query => {
    return request({
        url: '/admin/tag/index',
        method: 'get',
        params: query
    });
};
export const tagCreate = query => {
    return request({
        url: '/admin/tag/create',
        method: 'post',
        data: query
    });
};
export const tagUpdate = query => {
    return request({
        url: '/admin/tag/update',
        method: 'post',
        data: query
    });
};


// patient
export const patientList = query => {
    return request({
        url: '/admin/patient/index',
        method: 'get',
        params: query
    });
};

export const patientCreate = query => {
    return request({
        url: '/admin/patient/create',
        method: 'post',
        data: query
    });
};

export const patientUpdate = query => {
    return request({
        url: '/admin/patient/update',
        method: 'post',
        data: query
    });
};




// depart
export const departList = query => {
    return request({
        url: '/depart/index',
        method: 'get',
        params: query
    });
};

export const departUser = query => {
    return request({
        url: '/depart/userDepart',
        method: 'get',
        params: query
    });
};


export const departAll = query => {
    return request({
        url: '/depart/allDepart',
        method: 'get',
        params: query
    });
};

export const departCreate = query => {
    return request({
        url: '/depart/create',
        method: 'post',
        data: query
    });
};

export const departUpdate = query => {
    return request({
        url: '/depart/update',
        method: 'post',
        data: query
    });
};

// staff
export const staffList = query => {
    return request({
        url: '/staff/index',
        method: 'get',
        params: query
    });
};
export const staffAll = query => {
    return request({
        url: '/staff/allStaff',
        method: 'get',
        params: query
    });
};

export const staffCreate = query => {
    return request({
        url: '/staff/create',
        method: 'post',
        data: query
    });
};

export const staffUpdate = query => {
    return request({
        url: '/staff/update',
        method: 'post',
        data: query
    });
};

// barcode
export const barcodeList = query => {
    return request({
        url: '/bar/index',
        method: 'get',
        params: query
    });
};

export const barcodeCreate = query => {
    return request({
        url: '/bar/create',
        method: 'post',
        data: query
    });
};

export const barcodeUpdate = query => {
    return request({
        url: '/bar/update',
        method: 'post',
        data: query
    });
};

// room
export const roomList = query => {
    return request({
        url: '/room/index',
        method: 'get',
        params: query
    });
};
export const roomAll = query => {
    return request({
        url: '/room/allRoom',
        method: 'get',
        params: query
    });
};

export const roomCreate = query => {
    return request({
        url: '/room/create',
        method: 'post',
        data: query
    });
};

export const roomUpdate = query => {
    return request({
        url: '/room/update',
        method: 'post',
        data: query
    });
};


// bed
export const bedList = query => {
    return request({
        url: '/bed/index',
        method: 'get',
        params: query
    });
};
export const bedAll = query => {
    return request({
        url: '/bed/allBed',
        method: 'get',
        params: query
    });
};
export const emptyBed = query => {
    return request({
        url: '/bed/emptyBed',
        method: 'get',
        params: query
    });
};

export const bedCreate = query => {
    return request({
        url: '/bed/create',
        method: 'post',
        data: query
    });
};

export const bedUpdate = query => {
    return request({
        url: '/bed/update',
        method: 'post',
        data: query
    });
};


export const patientAll = query => {
    return request({
        url: '/patient/allPatient',
        method: 'get',
        params: query
    });
};

export const saveHos = query => {
    return request({
        url: '/patient/saveHos',
        method: 'post',
        data: query
    });
};
export const clearBed = query => {
    return request({
        url: '/patient/clearBed',
        method: 'post',
        data: query
    });
};

// log
export const logList = query => {
    return request({
        url: '/log/index',
        method: 'get',
        params: query
    });
};

export const logCreate = query => {
    return request({
        url: '/log/create',
        method: 'post',
        data: query
    });
};

export const logUpdate = query => {
    return request({
        url: '/log/update',
        method: 'post',
        data: query
    });
};


// scan
export const scanList = query => {
    return request({
        url: '/scan/index',
        method: 'get',
        params: query
    });
};

export const scanCreate = query => {
    return request({
        url: '/scan/create',
        method: 'post',
        data: query
    });
};

export const scanUpdate = query => {
    return request({
        url: '/scan/update',
        method: 'post',
        data: query
    });
};


// advice
export const adviceList = query => {
    return request({
        url: '/advice/index',
        method: 'get',
        params: query
    });
};

export const adviceCreate = query => {
    return request({
        url: '/advice/create',
        method: 'post',
        data: query
    });
};

export const adviceUpdate = query => {
    return request({
        url: '/advice/update',
        method: 'post',
        data: query
    });
};


// dict
export const dictMsgType = query => {
    return request({
        url: '/dict/msgType',
        method: 'get',
        params: query
    });
};

export const dictEduType = query => {
    return request({
        url: '/dict/eduType',
        method: 'get',
        params: query
    });
};


export const dictBarType = query => {
    return request({
        url: '/dict/barType',
        method: 'get',
        params: query
    });
};

export const dictVitaType = query => {
    return request({
        url: '/dict/vitaType',
        method: 'get',
        params: query
    });
};


export const dictAdviceType = query => {
    return request({
        url: '/dict/adviceType',
        method: 'get',
        params: query
    });
};

export const dictImitateType = query => {
    return request({
        url: '/dict/imitateType',
        method: 'get',
        params: query
    });
};

// vital
export const vitalList = query => {
    return request({
        url: '/vital/index',
        method: 'get',
        params: query
    });
};


// alarm
export const alarmList = query => {
    return request({
        url: '/bell/index',
        method: 'get',
        params: query
    });
};


export const alarmCreate = query => {
    return request({
        url: '/bell/create',
        method: 'post',
        data: query
    });
};

export const alarmUpdate = query => {
    return request({
        url: '/bell/update',
        method: 'post',
        data: query
    });
};


export const alarmBed = query => {
    return request({
        url: '/bell/bed',
        method: 'post',
        data: query
    });
};


// edu
export const eduList = query => {
    return request({
        url: '/edu/index',
        method: 'get',
        params: query
    });
};


export const eduCreate = query => {
    return request({
        url: '/edu/create',
        method: 'post',
        data: query
    });
};

export const eduUpdate = query => {
    return request({
        url: '/edu/update',
        method: 'post',
        data: query
    });
};


// msg
export const msgList = query => {
    return request({
        url: '/msg/index',
        method: 'get',
        params: query
    });
};

export const msgDetail = query => {
    return request({
        url: '/msg/detail',
        method: 'get',
        params: query
    });
};


export const msgCreate = query => {
    return request({
        url: '/msg/create',
        method: 'post',
        data: query
    });
};

export const msgUpdate = query => {
    return request({
        url: '/msg/update',
        method: 'post',
        data: query
    });
};


export const msgLogList = query => {
    return request({
        url: '/msgLog/index',
        method: 'get',
        params: query
    });
};


// imitate
export const imitateList = query => {
    return request({
        url: '/imitate/index',
        method: 'get',
        params: query
    });
};

export const imitateCreate = query => {
    return request({
        url: '/imitate/create',
        method: 'post',
        data: query
    });
};

export const imitateUpdate = query => {
    return request({
        url: '/imitate/update',
        method: 'post',
        data: query
    });
};


